#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START apt-rpm
#
# depends: rpm
# depends: setproctitle

VERSION=`awk '/^Version:/ { print $2 }' < apt-rpm/apt.spec`
RELEASE=`awk '/^Release:/ { print $2 }' < apt-rpm/apt.spec`
DISTTAG=p10 # just for fun

reset_mtime apt-rpm apt-rpm/configure.ac
rm -rf build/apt-rpm
mkdir -p build/apt-rpm
cd build/apt-rpm
../../apt-rpm/configure \
	${CONFIGURE_ARGS} \
	--includedir=$prefix/include/apt-pkg \
	--disable-scripts \
	--disable-static \
	--without-https \
	${AUTOCRAP_KLUDGE}

cat >> include/config.h <<-EOF
#define APTRPM_ID "apt-${VERSION}-${RELEASE}:${DISTTAG}._${TARGET%%-*}"
EOF
make -j${JOBS}
make -j${JOBS} install DESTDIR=`pwd`/inst
wipe_la_files "`pwd`/inst"

cd inst
find . | cpio -pumd "$stage"
cd ../../..
rm -rf build/apt-rpm

cd apt-rpm
find etc | cpio -pumd "$stage"
cd ..

# RECIPE END apt-rpm
